//
//  WFButtonText.m
//  谷居
//
//  Created by dllo on 16/6/18.
//  Copyright © 2016年 刘万方. All rights reserved.
//

#import "WFButtonText.h"

@implementation WFButtonText
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setColor];
        
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeToNight:) name:@"夜间模式" object:nil];

        
    }
    return self;
}
-(void)changeToNight:(NSNotification *)sender {
    
    if (!IS_LONG) {
        [self setBackgroundColor:NIGHT_COLOR];
        [self setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    } else {
        [self setBackgroundColor:DAY_COLOR];
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }
}

- (void)setColor {
    if (!IS_LONG) {
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self setBackgroundColor:DAY_COLOR];

    } else {
        [self setTitleColor:[UIColor lightTextColor] forState:UIControlStateNormal];
        [self setBackgroundColor:NIGHT_COLOR];

    }
}
@end
